﻿using System;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;

namespace SHomeWorkshop.LunarPresentation.Converts
{
    public sealed class MarginConverter : IMultiValueConverter
    {
        #region IMultiValueConverter Members

        object IMultiValueConverter.Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values[2] is Orientation)
            {
                if ((Orientation)values[2] == Orientation.Horizontal)
                {
                    return new Thickness(1);
                }
                else
                {
                    double d = (double)values[0] * 2 * (int)values[1];
                    return new Thickness(d < 1 ? 1 : d, 1, 1, 1);
                }
            }
            else
            {
                return new Thickness(1);
            }
        }

        object[] IMultiValueConverter.ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            return null;
        }

        #endregion
    }
}
